# Maintainer: CruX <crux@project-insanity.org>
# Contributor: pepedog at archlinuxarm dot com
# Contributor: Oleg Rakhmanov <oleg [at] archlinuxarm [dot] org>

buildarch=4
pkgname=firmware-imx
pkgver=8.24.r0.fbe0a4c
pkgrel=1
pkgdesc="Freescale proprietary firmware for i.MX6 SoC"
url="https://community.freescale.com/docs/DOC-95560"
arch=('armv7h')
license=('proprietay')
source=("https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/${pkgname}-${pkgver//.r0./-}.bin")
sha256sums=('2e27962332197ebebbb30138f6dfb365361d48d7efa565df97c4f79285b1ca50')

prepare() {
  cd "${srcdir}"
  #extract the firmware
  sh ${pkgname}-${pkgver//.r0./-}.bin --force --auto-accept
}

package() {
  mkdir -p "${pkgdir}/usr/lib/firmware/vpu"
  cp "${srcdir}/${pkgname}-${pkgver//.r0./-}/firmware/vpu/vpu_fw_imx6d.bin" "${pkgdir}/usr/lib/firmware/vpu"
  cp "${srcdir}/${pkgname}-${pkgver//.r0./-}/firmware/vpu/vpu_fw_imx6q.bin" "${pkgdir}/usr/lib/firmware/vpu"

  install -D -m0644 "${srcdir}/${pkgname}-${pkgver//.r0./-}/COPYING" "${pkgdir}/opt/fsl/licenses/LICENSE.${pkgname}"
  
  mkdir -p "${pkgdir}/etc/ld.so.conf.d"
  echo "/opt/fsl/lib" > "${pkgdir}/etc/ld.so.conf.d/${pkgname}.conf"
}
